﻿using Cmp.Web.Common;
using Cmp.Web.IRepository;
using Cmp.Web.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Threading.Tasks;

namespace Cmp.Web.Repository
{
    /// <summary>
    /// 医生数据获取实现
    /// </summary>
    public class DoctorProvide : DbContext<DoctorInfo>, IDoctorProvide
    {
        public Task<List<DoctorInfo>> GetDoctorInfoList(out ExceptionAll exception)
        {
            exception = new ExceptionAll();
            try
            {
                return Task.FromResult(Db.Queryable<DoctorInfo>().ToList());
            }
            catch (Exception ex)
            {
                exception.errMsg = ex.Message;
                exception.Action = System.Reflection.MethodBase.GetCurrentMethod()!.Name;
                exception.errMsgId = ErrorType.MyInterfaceError;
                exception.Exception = ex;
            }
            return null;
        }

        public Task<List<DoctorInfo>> GetDoctorInfoListByDeptCode(string DeptCode,out ExceptionAll exception)
        {
            exception= new ExceptionAll();
            try
            {
                return Task.FromResult(Db.Queryable<DoctorInfo>().Where(x => x.DeptCode == DeptCode).ToList());
            }
            catch (Exception ex)
            {
                exception.errMsg = ex.Message;
                exception.Action = System.Reflection.MethodBase.GetCurrentMethod()!.Name;
                exception.errMsgId = ErrorType.MyInterfaceError;
                exception.Exception = ex;
            }
            return null;
        }
    }
}
